home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / mint / netlib / include / in.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-27  |  2.2 KB  |  83 lines

  1. #ifndef _IN_H
  2. #define _IN_H
  3.  
  4. /* well-defined IP protocols */
  5. #define IPPROTO_IP    0
  6. #define IPPROTO_ICMP    1
  7. #define IPPROTO_TCP    6
  8. #define IPPROTO_UDP    17
  9. #define IPPROTO_RAW    255
  10. #define IPPROTO_MAX    IPPROTO_RAW
  11.  
  12. #define IS_INET_PROTO(p) \
  13.     ((p) == IPPROTO_ICMP || (p) == IPPROTO_TCP || (p) == IPPROTO_UDP)
  14.  
  15. /* well-known IP ports */
  16. #define IPPORT_RESERVED        1024
  17. #define IPPORT_USERRESERVED    5000
  18.  
  19. /* internet address */
  20. struct in_addr {
  21.     unsigned long s_addr;
  22. };
  23.  
  24. /* definitions for classifying an internet address */
  25. #define    IN_CLASSA(a)        ((((long)(a)) & 0x80000000) == 0)
  26. #define    IN_CLASSA_NET        0xff000000ul
  27. #define    IN_CLASSA_NSHIFT    24
  28. #define    IN_CLASSA_HOST        (0xffffffff & ~IN_CLASSA_NET)
  29. #define    IN_CLASSA_MAX        128
  30.  
  31. #define    IN_CLASSB(a)        ((((long)(a)) & 0xc0000000) == 0x80000000)
  32. #define    IN_CLASSB_NET        0xffff0000ul
  33. #define    IN_CLASSB_NSHIFT    16
  34. #define    IN_CLASSB_HOST        (0xffffffff & ~IN_CLASSB_NET)
  35. #define    IN_CLASSB_MAX        65536
  36.  
  37. #define    IN_CLASSC(a)        ((((long)(a)) & 0xe0000000) == 0xc0000000)
  38. #define    IN_CLASSC_NET        0xffffff00ul
  39. #define    IN_CLASSC_NSHIFT    8
  40. #define    IN_CLASSC_HOST        (0xffffffff & ~IN_CLASSC_NET)
  41.  
  42. #define    IN_CLASSD(a)        ((((long)(a)) & 0xf0000000) == 0xe0000000)
  43.  
  44. /* well-defined IP addresses */
  45. #define    INADDR_ANY        ((unsigned long)0x00000000)
  46. #define    INADDR_BROADCAST    ((unsigned long)0xffffffff)
  47. #define    INADDR_NONE        ((unsigned long)0xffffffff)
  48. #define    INADDR_LOOPBACK        ((unsigned long)0x7f000001)
  49.  
  50. #define IN_LOOPBACKNET        127
  51.  
  52. /* structure describing an Internet socket address */
  53. struct sockaddr_in {
  54.     short        sin_family;
  55.     unsigned short    sin_port;
  56.     struct in_addr    sin_addr;
  57.     char        sin_zero[8];
  58. };
  59.  
  60. /* options for use with [s|g]etsockopt' call at the IPPROTO_IP level */
  61. #define    IP_OPTIONS    1
  62. #define    IP_HDRINCL    2
  63. #define    IP_TOS        3
  64. #define    IP_TTL        4
  65. #define    IP_RECVOPTS    5
  66. #define    IP_RECVRETOPTS    6
  67. #define    IP_RECVDSTADDR    7
  68. #define    IP_RETOPTS    8
  69.  
  70. /* structure for use with IP_OPTIONS and IP_RETOPTS */
  71. struct ip_opts {
  72.     struct in_addr    ip_dst;
  73.     char        ip_opts[40];
  74. };
  75.  
  76. /* functions to convert between host and network byte order (big endian) */
  77. #define    ntohl(x)    (x)
  78. #define    ntohs(x)    (x)
  79. #define    htonl(x)    (x)
  80. #define    htons(x)    (x)
  81.  
  82. #endif    /* _IN_H */
  83.